import { noLoginPages } from '@/consts/pages.js'
import store from '@/store/index.js'
import { showLoginPopup } from '@/utils/login.js'


export default{
	
	methods:{
		
		/**
		 * 提示
		 */
		toast(title, mask = false, icon = 'none', duration = 2000) {
			uni.showToast({
				icon,
				mask,
				title,
				duration
			})
		},
		
		/**
		 * 跳转页面，校验是否登录
		 * 
		 */
		navTo(url){
			const shortUrl = url.split('?')[0]
			// 当前跳转的页面需要登录
			if(noLoginPages.indexOf(shortUrl) == -1 && !store.getters.isLogin){
				showLoginPopup()
			}else{
				uni.navigateTo({
					url	// 绝对路径
				})
			}
		}
	}
}
